﻿<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
Class Mdelivery extends MY_Model
{
    public function __construct()
    {
        parent::__construct();
    }
    
    public function getHomeDelivery()
    {
        $data = $this->db->query("SELECT * FROM home_delivery LIMIT 1")->row_object();
        return $data;
    }
    
    private function remove_null_tags($st){
		$Char 	= '<p> </p>|<p>&nbsp;</p>|<p></p>|<span> </span>|<span>&nbsp;</span>|<span></span>|<div> </div>|<div>&nbsp;</div>|<div></div>';
		$explChar 	= explode("|", $Char);
		return str_replace($explChar, '', $st);
	}
    public function homeDeliveryDb($title,$img,$content)
    {
        $post = strip_tags($content,"<a><br>");
        $data = array(
            'title' => $title,
            'content' => html_entity_decode($this->remove_null_tags($post), ENT_QUOTES, "UTF-8")
        );
        if(!in_array($img, array(null, '')))
        {
            $data['features'] = $img;
        }
        //die(print_r($data));
        $this->db->update('home_delivery', $data, "id = 1");
        $this->db->update('options', array('content' => time()), "tags = 'time_update_api_static'");
        return 200;
    }
}